<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<infopost-request>
			<xsl:for-each select="ABCB2I">
				<request-head>
					<xsl:for-each select="Header">
						<!-- 试算申请顺序号 -->
						<trans-id>
							<xsl:value-of select="SerialNo" />
						</trans-id>
						<trans-date>
							<xsl:value-of select="TransDate" />
						</trans-date>
						<trans-time>
							<xsl:value-of select="TransTime" />
						</trans-time>
						<bank>203</bank>
						<insu-id>
							<xsl:value-of select="CorpNo" />
						</insu-id>
						<trans-type>205</trans-type>
						<branch />
						<agency-hand>
							<xsl:value-of select="Tlid" />
						</agency-hand>
						<authorized />
					</xsl:for-each>
				</request-head>
				<request-newbiz>
					<request-underwriting>
						<xsl:for-each select="App">
							<xsl:for-each select="Req">
								<application>
									<policy-holder>
										<xsl:for-each select="Appl">
											<!-- 性别 -->
											<xsl:call-template name="GenderCode">
												<xsl:with-param name="srcCode" select="Sex" />
											</xsl:call-template>
											<!-- 出生日期 -->
											<birthday>
												<xsl:value-of select="Birthday" />
											</birthday>
										</xsl:for-each>
									</policy-holder>
									<life-assureds></life-assureds>
									<beneficiaries></beneficiaries>
									<products>
										<product>
											<xsl:for-each select="Risks">
												<product-code>
													<xsl:value-of select="RiskCode" />
												</product-code>
												<discount-prem>
													<xsl:value-of select="Prem" />
												</discount-prem>
												<amount>
													<xsl:value-of select="Amnt" />
												</amount>
												<!-- 交费期间类型 -->
												<xsl:call-template name="ChargePeriodCode">
													<xsl:with-param name="srcCode" select="PayDueType" />
												</xsl:call-template>
												<!-- 交费期间 -->
												<charge-year>
													<xsl:value-of select="PayDueDate" />
												</charge-year>
												<!-- 保险期间类型 -->
												<xsl:call-template name="CoveragePeriodCode">
													<xsl:with-param name="srcCode" select="InsuDueType" />
												</xsl:call-template>
												<!-- 保险期间 -->
												<coverage-year>
													<xsl:value-of select="InsuDueDate" />
												</coverage-year>
											</xsl:for-each>
										</product>
									</products>
								</application>
							</xsl:for-each>
						</xsl:for-each>
					</request-underwriting>
				</request-newbiz>
			</xsl:for-each>
		</infopost-request>
	</xsl:template>
	<xsl:template name="GenderCode">
		<xsl:param name="srcCode" />
		<xsl:choose>
			<xsl:when test="$srcCode = 0">
				<gender>M</gender>
			</xsl:when>
			<xsl:when test="$srcCode = 1">
				<gender>F</gender>
			</xsl:when>
			<xsl:when test="$srcCode = 2">
				<gender>N</gender>
			</xsl:when>
			<xsl:when test="$srcCode = ''">
				<gender />
			</xsl:when>
			<xsl:otherwise>
				<gender>CODE_NOT_EXIST</gender>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="ChargePeriodCode">
		<xsl:param name="srcCode" />
		<xsl:choose>
			<xsl:when test="$srcCode = 1">
				<charge-period>3</charge-period>
			</xsl:when>
			<xsl:when test="$srcCode = 4">
				<charge-period>2</charge-period>
			</xsl:when>
			<xsl:when test="$srcCode = 0">
				<charge-period>1</charge-period>
			</xsl:when>
			<xsl:when test="$srcCode = 2">
				<charge-period>4</charge-period>
			</xsl:when>
			<xsl:when test="$srcCode = 3">
				<charge-period>4</charge-period>
			</xsl:when>
			<xsl:when test="$srcCode = 5">
				<charge-period>4</charge-period>
			</xsl:when>
			<xsl:when test="$srcCode = ''">
				<charge-period />
			</xsl:when>
			<xsl:otherwise>
				<charge-period>CODE_NOT_EXIST</charge-period>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="CoveragePeriodCode">
		<xsl:param name="srcCode" />
		<xsl:choose>
			<xsl:when test="$srcCode = 0">
				<coverage-period>0</coverage-period>
			</xsl:when>
			<xsl:when test="$srcCode = 1">
				<coverage-period>4</coverage-period>
			</xsl:when>
			<xsl:when test="$srcCode = 2">
				<coverage-period>4</coverage-period>
			</xsl:when>
			<xsl:when test="$srcCode = 3">
				<coverage-period>4</coverage-period>
			</xsl:when>
			<xsl:when test="$srcCode = 4">
				<coverage-period>2</coverage-period>
			</xsl:when>
			<xsl:when test="$srcCode = 5">
				<coverage-period>3</coverage-period>
			</xsl:when>
			<xsl:when test="$srcCode = 6">
				<coverage-period>1</coverage-period>
			</xsl:when>
			<xsl:otherwise>
				<coverage-period>CODE_NOT_EXIST</coverage-period>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
